# $Id: PKGBUILD 141111 2011-10-24 09:59:20Z dreisner $
# Maintainer: Dave Reisner <dreisner@archlinux.org>
# Maintainer: Thomas Bächler <thomas@archlinux.org>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - removed -mtune, changed -march to v8/v7/v6/v5 compat

pkgname=mkinitcpio-busybox
pkgver=1.21.1
pkgrel=2
pkgdesc="base initramfs tools"
arch=('i686' 'x86_64')
url="http://www.busybox.net/"
license=('GPL')
depends=('glibc')
options=('!buildflags')
source=("http://busybox.net/downloads/busybox-$pkgver.tar.bz2"
        'glibc-2.16.patch'
        'config')
sha256sums=('cd5be0912ec856110ae12c76c3ec9cd5cba1df45b5a9da2b095b8284d1481303'
            'fb5b6e2a0de4db5401322e5c2474ad8ce6a58615dad45b7109cfe045baf2c88d'
            '240c9ab805fbf5eb3347b2a42f62d840f160c4999d0f172b28ba50dadad09ada')

prepare() {
  cd "busybox-$pkgver"

  if [ ${CARCH} = "aarch64" ]; then
    ARMCARCH="armv8-a"
  elif [ ${CARCH} = "armv7h" ]; then
    ARMCARCH="armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16"
  elif [ ${CARCH} = "armv6h" ]; then
    ARMCARCH="armv6 -mfloat-abi=hard -mfpu=vfp"
  else
    ARMCARCH="armv5te"
  fi

  local safeflags="-march=${ARMCARCH} -Os -pipe -fno-strict-aliasing"

  sed 's|^\(CONFIG_EXTRA_CFLAGS\)=.*|\1="'"$safeflags"'"|' "$srcdir/config" >.config

  patch -Np1 < "$srcdir/glibc-2.16.patch"
}

build() {
  make -C "busybox-$pkgver"
}

package() {
  install -Dm755 "$srcdir/busybox-$pkgver/busybox" "$pkgdir/usr/lib/initcpio/busybox"
}

# vim:set ts=2 sw=2 et:
